package com.ljx.itbbs.server.article.controller;

import com.ljx.itbbs.common.domain.vo.resp.ApiResult;
import com.ljx.itbbs.server.article.domain.vo.req.admin.PlateAdminSaveReq;
import com.ljx.itbbs.server.article.domain.vo.req.admin.PlateAdminUpdateReq;
import com.ljx.itbbs.server.article.domain.vo.resp.PlateResp;
import com.ljx.itbbs.server.article.domain.vo.resp.admin.PlateAdminResp;
import com.ljx.itbbs.server.article.domain.vo.resp.admin.PlaterQueryResp;
import com.ljx.itbbs.server.article.service.PlateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "板块接口")
@RestController
@RequestMapping("/plate")
public class PlateController {

    @Autowired
    private PlateService plateService;

    @ApiOperation("获取所有板块")
    @GetMapping("/all")
    public ApiResult<List<PlateResp>> getAllPlate(){

        return ApiResult.success(plateService.getAllPlate());
    }

    @ApiOperation("管理员获取所有板块")
    @GetMapping("/admin/list")
    public ApiResult<List<PlateAdminResp>> adminPlateList(){

        return ApiResult.success(plateService.adminPlateList());
    }

    @ApiOperation("管理员修改板块")
    @PutMapping("/admin/update")
    public ApiResult<Void> adminUpdatePlate(@Valid @RequestBody PlateAdminUpdateReq req){
        plateService.adminUpdatePlate(req);

        return ApiResult.success();
    }

    @ApiOperation("管理员保存板块")
    @PutMapping("/admin/save")
    public ApiResult<Void> adminSavePlate(@Valid @RequestBody PlateAdminSaveReq req){
        plateService.adminSavePlate(req);

        return ApiResult.success();
    }

    @ApiOperation("管理员查询板块版主列表")
    @GetMapping("/admin/plater/list")
    public ApiResult<List<PlaterQueryResp>> adminQueryPlaterList(@RequestParam("plateId") Long plateId){

        return ApiResult.success(plateService.adminQueryPlaterList(plateId));
    }



}
